﻿using iBuproModel.Repositories;
using iBuproModel.Repositories.Classes;
using iBuproModel.Repositories.Interfaces;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using iBuproModel;
using System.Collections.Generic;
using System.Linq;

namespace IBuproModel.Tests
{
    
    
    /// <summary>
    ///This is a test class for DepartmentRepositoryTest and is intended
    ///to contain all DepartmentRepositoryTest Unit Tests
    ///</summary>
    [TestClass()]
    public class DepartmentRepositoryTest
    {

        

        private TestContext testContextInstance;
        Random rand = new Random();
        private UserRepository users = new UserRepository();
        

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for UpdatePrincipalList
        ///</summary>
        [TestMethod()]
        public void UpdatePrincipalListTest()
        {
            DepartmentRepository target = new DepartmentRepository(); 

            var dep = new Department()
                          {
                              Name = "aaa"
                          };
            target.Add(dep);
            target.SaveChanges();
            target.UpdatePrincipalList(dep,new List<int>());
        }

        /// <summary>
        ///A test for UpdateAdministratorList
        ///</summary>
        [TestMethod()]
        public void UpdateAdministratorListTest()
        {
            DepartmentRepository target = new DepartmentRepository(); 

            var dep = new Department()
            {
                Name = "aaa"
            };
           
            target.UpdateAdministratorList(dep, new List<int>());
        }

        /// <summary>
        ///A test for GetDepartmentsForUser
        ///</summary>
        [TestMethod()]
        public void GetDepartmentsForUserTest()
        {
            DepartmentRepository target = new DepartmentRepository(); 


            var user = users.First(u => u.Username == "admin");

            var ret = target.GetDepartmentsForUser(user);

            Assert.IsNotNull(ret);
        }

        /// <summary>
        ///A test for GetAll
        ///</summary>
        [TestMethod()]
        public void GetAllTest()
        {
            DepartmentRepository target = new DepartmentRepository(); 
            IQueryable<Department> actual;
            actual = target.GetAll();
            Assert.IsNotNull(actual);
        }

        /// <summary>
        ///A test for DepartmentRepository Constructor
        ///</summary>
        [TestMethod()]
        public void DepartmentRepositoryConstructorTest()
        {
            DepartmentRepository target = new DepartmentRepository();
            Assert.IsNotNull(target);
        }
    }
}
